﻿//
//   Description:       Pixel shader that samples the color from an image and draws every odd row transparent.
//
//   Changed by:        $Author: Rene $
//   Changed on:        $Date: 2009-10-23 21:21:45 +0200 (Fr, 23 Okt 2009) $
//   Changed in:        $Revision: 49 $
//   Project:           $URL: file:///U:/Data/Development/SVN/SilverlightDemos/trunk/Shaders/ShaderSilverlightTestproject/ShaderSilverlightTestproject/Shader/TransparentAlternatingScanlinesEffect.cs $
//   Id:                $Id: TransparentAlternatingScanlinesEffect.cs 49 2009-10-23 19:21:45Z Rene $
//
//
//   Copyright (c) 2009 Rene Schulte
//
//   This program is open source software. Please read the License.txt.
//

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Media3D;


namespace TheOliver.Controls.ShaderEffects
{
    public class TransparentAlternatingScanlinesEffect : ShaderEffect
    {
        #region Properties

        public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(TransparentAlternatingScanlinesEffect), 0);
        public static readonly DependencyProperty TextureSizeProperty = DependencyProperty.Register("TextureSize", typeof(Point), typeof(TransparentAlternatingScanlinesEffect), new PropertyMetadata(new Point(512, 512), PixelShaderConstantCallback(0)));

        public Brush Input
        {
            get
            {
                return ((Brush)(this.GetValue(InputProperty)));
            }
            set
            {
                this.SetValue(InputProperty, value);
            }
        }

        /// <summary>The Size of the texture.</summary>
        public Point TextureSize
        {
            get
            {
                return ((Point)(this.GetValue(TextureSizeProperty)));
            }
            set
            {
                this.SetValue(TextureSizeProperty, value);
            }
        }

        #endregion

        #region Contructors

        public TransparentAlternatingScanlinesEffect()
        {
            PixelShader pixelShader = new PixelShader();
            //{
            //   UriSource = new Uri("/ShaderSilverlightTestproject;component/Shader/TransparentAlternatingScanlines.ps", UriKind.Relative)
            //};
            pixelShader.UriSource = Global.MakePackUri("ShaderSource/TransparentAlternatingScanlines.ps");

            this.PixelShader = pixelShader;

            this.UpdateShaderValue(InputProperty);
            this.UpdateShaderValue(TextureSizeProperty);
        }

        #endregion
    }
}
